home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
SNIP9_91.ARJ
/
DOSCOPY.C
< prev
next >
Wrap
Text File
|
1991-08-08
|
2KB
|
52 lines
/***************************************************
* function : copy *
* purpose : copy one file *
* *
* arguments: path to source 'fromDir', *
* path to target 'toDir', *
* filename to copy 'fname' *
* *
* returns : 0 *
* *
* By : Peter Yard (29 May 1991) *
***************************************************/
int copy(char *fromDir, char *fname, char *toDir)
{
FILE *nul; /* nul will redirect stdout to DOS 'nul' */
char from[PathSize], to[PathSize], comd[120];
int bytesRead, oldStdout;
/* Create the strings to describe the paths */
make_path(from,fromDir,fname);
make_path(to,toDir,fname);
/* Construct 'comd' string which is a dos command for a copy */
strcpy(comd,"copy ");
strcat(comd,from); strcat(comd," ");
strcat(comd,to);
/* Redirect stdout to a nul file, kills output to the screen */
nul = fopen("NUL","w");
oldStdout = dup(STDOUT);
dup2(fileno(nul),STDOUT);
close(fileno(nul));
system(comd); /* COPY file */
/* Restore stdout and close nul file */
dup2(oldStdout,STDOUT);
close(oldStdout);
/* Display file source and target, */
/* otherwise comment out the next line. */
printf("\n%s copied to %s",from,to);
return 0;
}